package com.wkbb.basic.thread;

import com.wkbb.basic.model.YoutuPerson;
import com.wkbb.basic.service.YouTuService;
import com.wkbb.basic.utils.FileUtil;
import com.wkbb.basic.utils.ImageOfbase64UtilDto;
import lombok.extern.slf4j.Slf4j;

import java.net.URL;
import java.util.List;

/**
 * @author dengjingyuan
 * @date 2019-12-21 20:31
 */
@Slf4j
public class BasicRepairAddUserFaceTask implements Runnable {

    private YouTuService youTuService;

    private String faceUrl;

    private List<YoutuPerson> youtuPersonList;

    private Object orgId;

    public BasicRepairAddUserFaceTask(YouTuService youTuService, String faceUrl, List<YoutuPerson> youtuPersonList, Object orgId) {
        this.youTuService = youTuService;
        this.faceUrl = faceUrl;
        this.youtuPersonList = youtuPersonList;
        this.orgId = orgId;
    }

    public BasicRepairAddUserFaceTask() {

    }

    @Override
    public void run() {
        log.info("*********开始修复人脸数据********youTuService:{},faceUrl:{},youtuPersonList:{},orgId:{}", youTuService, faceUrl,youtuPersonList,orgId);
        try {
            youTuService.repairAddUserFaceAsyn(new ImageOfbase64UtilDto(faceUrl, FileUtil.encodeImageToBase64(new URL(faceUrl))), youtuPersonList, orgId);
        } catch (Exception e) {
            log.error("*******BasicRepairAddUserFaceTask**********:{}", e.getMessage());
        }
    }
}